#include <gtest/gtest.h>
#include <iostream>
#include <vector>

class MyTest : public testing::Environment
{
public:
    virtual void SetUp() override
    {
        std::cout << "单元测试执行前的环境初始化！！\n";
    }

    virtual void TearDown() override
    {
        std::cout << "单元测试执行完毕后的环境清理！！\n";
    }
};

TEST(MyTest, test1)
{
    std::cout << "unit test one";
}


TEST(MyTest, test2)
{
    std::cout << "unit test two";
}

std::vector<int> vec;
class VecTest : public testing::Environment
{
public:
    virtual void SetUp() override
    {
        std::cout << "registering..." << std::endl;
        vec.push_back(1);   
        vec.push_back(2);   
        vec.push_back(3);   
    }

    virtual void TearDown() override
    {
        std::cout << "clearing..." << std::endl;
        vec.clear();
    }

};

TEST(Vec, testvec)
{
    ASSERT_EQ(vec.size(), 3);
    vec.pop_back();
}

TEST(Vec, testVec)
{
    ASSERT_EQ(vec.size(), 2);
}

int main(int argc, char* argv[])
{
    testing::InitGoogleTest(&argc, argv);

    testing::AddGlobalTestEnvironment(new MyTest);
    testing::AddGlobalTestEnvironment(new VecTest);

    RUN_ALL_TESTS();

    return 0;
}